﻿using System.Linq;

namespace iHouse.Infrastructure
{
    public static class PagingExtensions
    {
        #region IQueryable<T> extensions

        public static PaginationList<T> ToPaginationList<T>(this IQueryable<T> source, int pageIndex, int pageSize)
        {
            return new PaginationList<T>(source, pageIndex, pageSize, string.Empty);
        }

        public static PaginationList<T> ToPaginationList<T>(this IQueryable<T> source, PagingCriteria criteria)
        {
            return new PaginationList<T>(source, criteria.PageIndex, criteria.PageSize, criteria.SearchString, criteria.SearchValues);
        }

        public static JqGridList<T> ToJqGridList<T>(this IQueryable<T> source, PagingCriteria criteria)
        {
            return new JqGridList<T>(source, criteria.PageIndex, criteria.PageSize, criteria.Sidx, criteria.Sord, criteria.SearchString, criteria.SearchValues);
        }

        #endregion
    }
}